/**
 * <copyright>
 *
 * Copyright (c) 2011 Zeligsoft (2009) Limited
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: 
 *   Zeligsoft (2009) Limited - Initial API and implementation
 *
 * </copyright>
 *
 */
package org.omg.deployment.parts.forms;

import org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent;
import org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart;
import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart;
import org.eclipse.emf.eef.runtime.ui.parts.PartComposer;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.BindingCompositionSequence;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.CompositionSequence;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.CompositionStep;
import org.eclipse.emf.eef.runtime.ui.utils.EditingUtils;
import org.eclipse.emf.eef.runtime.ui.widgets.FormUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.omg.deployment.parts.DeploymentViewsRepository;
import org.omg.deployment.parts.PlanSubcomponentPortEndpointPropertiesEditionPart;
import org.omg.deployment.providers.DeploymentMessages;


/**
 * @author Toby McClean; Zeligsoft (2009) Limited
 * @generated
 */
public class PlanSubcomponentPortEndpointPropertiesEditionPartForm extends CompositePropertiesEditionPart implements IFormPropertiesEditionPart, PlanSubcomponentPortEndpointPropertiesEditionPart {

	protected Text portName;
	protected Text provider;
	protected Text kind;
	protected Text instance;



	/**
	 * Default constructor
	 * @param editionComponent the {@link IPropertiesEditionComponent} that manage this part
	 * @generated
	 */
	public PlanSubcomponentPortEndpointPropertiesEditionPartForm(IPropertiesEditionComponent editionComponent) {
    super(editionComponent);
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart#
	 *  createFigure(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit)
	 * @generated
	 */
	public Composite createFigure(final Composite parent, final FormToolkit widgetFactory) {
    ScrolledForm scrolledForm = widgetFactory.createScrolledForm(parent);
    Form form = scrolledForm.getForm();
    view = form.getBody();
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    view.setLayout(layout);
    createControls(widgetFactory, view);
    return scrolledForm;
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart#
	 *  createControls(org.eclipse.ui.forms.widgets.FormToolkit, org.eclipse.swt.widgets.Composite)
	 * @generated
	 */
	public void createControls(final FormToolkit widgetFactory, Composite view) {
    CompositionSequence planSubcomponentPortEndpointStep = new BindingCompositionSequence(propertiesEditionComponent);
    CompositionStep propertiesStep = planSubcomponentPortEndpointStep.addStep(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.class);
    propertiesStep.addStep(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.portName);
    propertiesStep.addStep(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.provider);
    propertiesStep.addStep(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.kind);
    propertiesStep.addStep(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.instance);
    
    
    composer = new PartComposer(planSubcomponentPortEndpointStep) {

      @Override
      public Composite addToPart(Composite parent, Object key) {
        if (key == DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.class) {
          return createPropertiesGroup(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.portName) {
          return 		createPortNameText(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.provider) {
          return 		createProviderText(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.kind) {
          return 		createKindText(widgetFactory, parent);
        }
        if (key == DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.instance) {
          return 		createInstanceText(widgetFactory, parent);
        }
        return parent;
      }
    };
    composer.compose(view);
  }
	/**
	 * @generated
	 */
	protected Composite createPropertiesGroup(FormToolkit widgetFactory, final Composite parent) {
    Section propertiesSection = widgetFactory.createSection(parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    propertiesSection.setText(DeploymentMessages.PlanSubcomponentPortEndpointPropertiesEditionPart_PropertiesGroupLabel);
    GridData propertiesSectionData = new GridData(GridData.FILL_HORIZONTAL);
    propertiesSectionData.horizontalSpan = 3;
    propertiesSection.setLayoutData(propertiesSectionData);
    Composite propertiesGroup = widgetFactory.createComposite(propertiesSection);
    GridLayout propertiesGroupLayout = new GridLayout();
    propertiesGroupLayout.numColumns = 3;
    propertiesGroup.setLayout(propertiesGroupLayout);
    propertiesSection.setClient(propertiesGroup);
    return propertiesGroup;
  }

	/**
	 * @generated
	 */
	
	protected Composite createPortNameText(FormToolkit widgetFactory, Composite parent) {
    FormUtils.createPartLabel(widgetFactory, parent, DeploymentMessages.PlanSubcomponentPortEndpointPropertiesEditionPart_PortNameLabel, propertiesEditionComponent.isRequired(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.portName, DeploymentViewsRepository.FORM_KIND));
    portName = widgetFactory.createText(parent, ""); //$NON-NLS-1$
    portName.setEnabled(false);
    portName.setToolTipText(DeploymentMessages.PlanSubcomponentPortEndpoint_ReadOnly);
    portName.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    widgetFactory.paintBordersFor(parent);
    GridData portNameData = new GridData(GridData.FILL_HORIZONTAL);
    portName.setLayoutData(portNameData);
    portName.addFocusListener(new FocusAdapter() {
      /**
       * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void focusLost(FocusEvent e) {
        if (propertiesEditionComponent != null)
          propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(PlanSubcomponentPortEndpointPropertiesEditionPartForm.this, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.portName, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, portName.getText()));
      }
    });
    portName.addKeyListener(new KeyAdapter() {
      /**
       * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void keyPressed(KeyEvent e) {
        if (e.character == SWT.CR) {
          if (propertiesEditionComponent != null)
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(PlanSubcomponentPortEndpointPropertiesEditionPartForm.this, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.portName, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, portName.getText()));
        }
      }
    });
    EditingUtils.setID(portName, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.portName);
    EditingUtils.setEEFtype(portName, "eef::Text"); //$NON-NLS-1$
    FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.portName, DeploymentViewsRepository.FORM_KIND), null); //$NON-NLS-1$
    return parent;
  }

	/**
	 * @generated
	 */
	
	protected Composite createProviderText(FormToolkit widgetFactory, Composite parent) {
    FormUtils.createPartLabel(widgetFactory, parent, DeploymentMessages.PlanSubcomponentPortEndpointPropertiesEditionPart_ProviderLabel, propertiesEditionComponent.isRequired(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.provider, DeploymentViewsRepository.FORM_KIND));
    provider = widgetFactory.createText(parent, ""); //$NON-NLS-1$
    provider.setEnabled(false);
    provider.setToolTipText(DeploymentMessages.PlanSubcomponentPortEndpoint_ReadOnly);
    provider.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    widgetFactory.paintBordersFor(parent);
    GridData providerData = new GridData(GridData.FILL_HORIZONTAL);
    provider.setLayoutData(providerData);
    provider.addFocusListener(new FocusAdapter() {
      /**
       * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void focusLost(FocusEvent e) {
        if (propertiesEditionComponent != null)
          propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(PlanSubcomponentPortEndpointPropertiesEditionPartForm.this, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.provider, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, provider.getText()));
      }
    });
    provider.addKeyListener(new KeyAdapter() {
      /**
       * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void keyPressed(KeyEvent e) {
        if (e.character == SWT.CR) {
          if (propertiesEditionComponent != null)
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(PlanSubcomponentPortEndpointPropertiesEditionPartForm.this, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.provider, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, provider.getText()));
        }
      }
    });
    EditingUtils.setID(provider, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.provider);
    EditingUtils.setEEFtype(provider, "eef::Text"); //$NON-NLS-1$
    FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.provider, DeploymentViewsRepository.FORM_KIND), null); //$NON-NLS-1$
    return parent;
  }

	/**
	 * @generated
	 */
	
	protected Composite createKindText(FormToolkit widgetFactory, Composite parent) {
    FormUtils.createPartLabel(widgetFactory, parent, DeploymentMessages.PlanSubcomponentPortEndpointPropertiesEditionPart_KindLabel, propertiesEditionComponent.isRequired(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.kind, DeploymentViewsRepository.FORM_KIND));
    kind = widgetFactory.createText(parent, ""); //$NON-NLS-1$
    kind.setEnabled(false);
    kind.setToolTipText(DeploymentMessages.PlanSubcomponentPortEndpoint_ReadOnly);
    kind.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    widgetFactory.paintBordersFor(parent);
    GridData kindData = new GridData(GridData.FILL_HORIZONTAL);
    kind.setLayoutData(kindData);
    kind.addFocusListener(new FocusAdapter() {
      /**
       * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void focusLost(FocusEvent e) {
        if (propertiesEditionComponent != null)
          propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(PlanSubcomponentPortEndpointPropertiesEditionPartForm.this, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.kind, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, kind.getText()));
      }
    });
    kind.addKeyListener(new KeyAdapter() {
      /**
       * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void keyPressed(KeyEvent e) {
        if (e.character == SWT.CR) {
          if (propertiesEditionComponent != null)
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(PlanSubcomponentPortEndpointPropertiesEditionPartForm.this, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.kind, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, kind.getText()));
        }
      }
    });
    EditingUtils.setID(kind, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.kind);
    EditingUtils.setEEFtype(kind, "eef::Text"); //$NON-NLS-1$
    FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.kind, DeploymentViewsRepository.FORM_KIND), null); //$NON-NLS-1$
    return parent;
  }

	/**
	 * @generated
	 */
	
	protected Composite createInstanceText(FormToolkit widgetFactory, Composite parent) {
    FormUtils.createPartLabel(widgetFactory, parent, DeploymentMessages.PlanSubcomponentPortEndpointPropertiesEditionPart_InstanceLabel, propertiesEditionComponent.isRequired(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.instance, DeploymentViewsRepository.FORM_KIND));
    instance = widgetFactory.createText(parent, ""); //$NON-NLS-1$
    instance.setEnabled(false);
    instance.setToolTipText(DeploymentMessages.PlanSubcomponentPortEndpoint_ReadOnly);
    instance.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    widgetFactory.paintBordersFor(parent);
    GridData instanceData = new GridData(GridData.FILL_HORIZONTAL);
    instance.setLayoutData(instanceData);
    instance.addFocusListener(new FocusAdapter() {
      /**
       * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void focusLost(FocusEvent e) {
        if (propertiesEditionComponent != null)
          propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(PlanSubcomponentPortEndpointPropertiesEditionPartForm.this, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.instance, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, instance.getText()));
      }
    });
    instance.addKeyListener(new KeyAdapter() {
      /**
       * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
       * @generated
       */
      @Override
      @SuppressWarnings("synthetic-access")
      public void keyPressed(KeyEvent e) {
        if (e.character == SWT.CR) {
          if (propertiesEditionComponent != null)
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(PlanSubcomponentPortEndpointPropertiesEditionPartForm.this, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.instance, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, instance.getText()));
        }
      }
    });
    EditingUtils.setID(instance, DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.instance);
    EditingUtils.setEEFtype(instance, "eef::Text"); //$NON-NLS-1$
    FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(DeploymentViewsRepository.PlanSubcomponentPortEndpoint.Properties.instance, DeploymentViewsRepository.FORM_KIND), null); //$NON-NLS-1$
    return parent;
  }



	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionListener#firePropertiesChanged(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
	 * @generated
	 */
	public void firePropertiesChanged(IPropertiesEditionEvent event) {
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.PlanSubcomponentPortEndpointPropertiesEditionPart#getPortName()
	 * @generated
	 */
	public String getPortName() {
    return portName.getText();
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.PlanSubcomponentPortEndpointPropertiesEditionPart#setPortName(String newValue)
	 * @generated
	 */
	public void setPortName(String newValue) {
    if (newValue != null) {
      portName.setText(newValue);
    } else {
      portName.setText(""); //$NON-NLS-1$
    }
  }


	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.PlanSubcomponentPortEndpointPropertiesEditionPart#getProvider()
	 * @generated
	 */
	public String getProvider() {
    return provider.getText();
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.PlanSubcomponentPortEndpointPropertiesEditionPart#setProvider(String newValue)
	 * @generated
	 */
	public void setProvider(String newValue) {
    if (newValue != null) {
      provider.setText(newValue);
    } else {
      provider.setText(""); //$NON-NLS-1$
    }
  }


	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.PlanSubcomponentPortEndpointPropertiesEditionPart#getKind()
	 * @generated
	 */
	public String getKind() {
    return kind.getText();
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.PlanSubcomponentPortEndpointPropertiesEditionPart#setKind(String newValue)
	 * @generated
	 */
	public void setKind(String newValue) {
    if (newValue != null) {
      kind.setText(newValue);
    } else {
      kind.setText(""); //$NON-NLS-1$
    }
  }


	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.PlanSubcomponentPortEndpointPropertiesEditionPart#getInstance()
	 * @generated
	 */
	public String getInstance() {
    return instance.getText();
  }

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.omg.deployment.parts.PlanSubcomponentPortEndpointPropertiesEditionPart#setInstance(String newValue)
	 * @generated
	 */
	public void setInstance(String newValue) {
    if (newValue != null) {
      instance.setText(newValue);
    } else {
      instance.setText(""); //$NON-NLS-1$
    }
  }




	/**
	 * {@inheritDoc}
	 *
	 * @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle()
	 * @generated
	 */
	public String getTitle() {
    return DeploymentMessages.PlanSubcomponentPortEndpoint_Part_Title;
  }



}
